cmake_minimum_required(VERSION 3.13)
project(labwc VERSION 0.7.1)

option(HAVE_XWAYLAND "" OFF)
option(HAVE_RSVG "" OFF)

add_definitions(-DHAVE_XWAYLAND=0)
add_definitions(-DHAVE_RSVG=0)
add_definitions(-DHAVE_NLS=0)
add_definitions(-DWLR_USE_UNSTABLE)
add_definitions(-DLABWC_VERSION="${PROJECT_VERSION}")
#add_project_arguments(
#  [
#    '-DWLR_USE_UNSTABLE',
#  ],
#  language: 'c',
#)
#
#cc = meson.get_compiler('c')
#
#add_project_arguments(cc.get_supported_arguments([
#  '-Wundef',
#  '-Wlogical-op',
#  '-Wmissing-include-dirs',
#  '-Wold-style-definition',
#  '-Wpointer-arith',
#  '-Winit-self',
#  '-Wstrict-prototypes',
#  '-Wimplicit-fallthrough=2',
#  '-Wendif-labels',
#  '-Wstrict-aliasing=2',
#  '-Woverflow',
#  '-Wmissing-prototypes',
#  '-Walloca',
#  '-Wunused-macros',
#
#  '-Wno-unused-parameter',
#]), language: 'c')
#
#version='"@0@"'.format(meson.project_version())
#git = find_program('git', native: true, required: false)
#if git.found()
#  git_commit = run_command([git, 'describe', '--dirty'], check: false)
#  if git_commit.returncode() == 0
#    version = '"@0@"'.format(git_commit.stdout().strip())
#  endif
#endif
#add_project_arguments('-DLABWC_VERSION=@0@'.format(version), language: 'c')
#
#wlroots = dependency(
#  'wlroots',
#  default_options: ['default_library=static', 'examples=false'],
#  version: ['>=0.17.0', '<0.18.0'],
#)
#
find_package(PkgConfig)
#wlroots_has_xwayland = wlroots.get_variable('have_xwayland') == 'true'
#

pkg_check_modules(PIXMAN IMPORTED_TARGET pixman-1)
pkg_check_modules(DRM IMPORTED_TARGET libdrm)
pkg_check_modules(CAIRO IMPORTED_TARGET cairo)
pkg_check_modules(PANGO IMPORTED_TARGET pango)
pkg_check_modules(PANGO_CAIRO IMPORTED_TARGET pangocairo)
pkg_check_modules(WLROOTS IMPORTED_TARGET wlroots)
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols)
pkg_check_modules(WAYLAND_SERVER IMPORTED_TARGET wayland-server)
pkg_check_modules(GLIB IMPORTED_TARGET glib-2.0)
pkg_check_modules(XML IMPORTED_TARGET libxml-2.0)
pkg_check_modules(PNG IMPORTED_TARGET libpng)
pkg_check_modules(XKBCOMMON IMPORTED_TARGET xkbcommon)
pkg_check_modules(INPUT IMPORTED_TARGET libinput)
#wayland_server = dependency('wayland-server', version: '>=1.19.0')
#wayland_protos = dependency('wayland-protocols')
#xkbcommon = dependency('xkbcommon')
#xcb = dependency('xcb', required: get_option('xwayland'))
#xcb_icccm = dependency('xcb-icccm', required: get_option('xwayland'))
#drm_full = dependency('libdrm')
#drm = drm_full.partial_dependency(compile_args: true, includes: true)
#xml2 = dependency('libxml-2.0')
#glib = dependency('glib-2.0')
#cairo = dependency('cairo')
#pangocairo = dependency('pangocairo')
#input = dependency('libinput', version: '>=1.14')
#pixman = dependency('pixman-1')
#math = cc.find_library('m')
#png = dependency('libpng')
#svg = dependency('librsvg-2.0', version: '>=2.46', required: false)
#
#if get_option('xwayland').enabled() and not wlroots_has_xwayland
#	error('no wlroots Xwayland support')
#endif
#have_xwayland = xcb.found() and wlroots_has_xwayland
#conf_data = configuration_data()

#conf_data.set10('HAVE_XWAYLAND', have_xwayland)
#
#if get_option('svg').disabled()
#  have_rsvg = false
#else
#  have_rsvg = svg.found()
#endif
#conf_data.set10('HAVE_RSVG', have_rsvg)
#
#msgfmt = find_program('msgfmt', required: get_option('nls'))
#if msgfmt.found()
#  source_root = meson.current_source_dir()
#  conf_data.set('HAVE_NLS', 1)
#  subdir('po')
#else
#  conf_data.set('HAVE_NLS', 0)
#endif
#
#labwc_inc = include_directories('include')
#
#subdir('protocols')
add_subdirectory(protocols)
#
#labwc_deps = [
#  server_protos,
#  wayland_server,
#  wlroots,
#  xkbcommon,
#  xcb_icccm,
#  xml2,
#  glib,
#  cairo,
#  drm,
#  pangocairo,
#  input,
#  pixman,
#  math,
#  png,
#]
#if have_rsvg
#  labwc_deps += [
#    svg,
#  ]
#endif
#
#add_subdirectory(include)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/config.h "")
include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_subdirectory(src)
#subdir('docs')
#
#executable(
#  meson.project_name(),
#  labwc_sources,
#  include_directories: [labwc_inc],
#  dependencies: labwc_deps,
#  install: true,
#)
#
#install_data('data/labwc.desktop', install_dir: get_option('datadir') / 'wayland-sessions')
#
#icons = ['labwc-symbolic.svg', 'labwc.svg']
#foreach icon : icons
#  icon_path = join_paths('data', icon)
#  install_data(icon_path, install_dir: get_option('datadir') / 'icons/hicolor/scalable/apps')
#endforeach
#
